package com.hx.er.action.manager.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErManagerAction;
import com.hx.er.bean.base.LanguageBean;
import com.hx.er.bean.base.UserBean;
import com.hx.er.common.system.ErLanguages;
import com.hx.er.service.manager.IManagerUserService;

public class ManagerUserViewAction extends ErManagerAction {
	// 序列化ID
	private static final long serialVersionUID = 1372417863805705188L;

	private UserBean userBeanPage;
	private List<Integer> ageList;
	private List<LanguageBean> langList;
	private Map<String, String> sexMap;

	@Autowired
	private IManagerUserService managerUserService;

	public String init() {
		// 初始化常量
		this.initPage();

		// 获取用户编号
		long userId = super.userInfoLogin.getUserId();
		// 获取用户信息
		this.userBeanPage = this.managerUserService.getUserAliveById(userId);
		return SUCCESS;
	}

	/**
	 * 初始化页面需要的下拉框等元素
	 */
	private void initPage() {
		// 初始化年龄，范围为1～100
		this.ageList = new ArrayList<Integer>();
		for (int i = 10; i < 100; i++) {
			this.ageList.add(i + 1);
		}

		// 初始化语言
		this.langList = ErLanguages.getLangList();

		// 初始化性别
		this.sexMap = new HashMap<String, String>();
		this.sexMap.put("0", "女");
		this.sexMap.put("1", "男");
	}

	public UserBean getUserBeanPage() {
		return userBeanPage;
	}

	public void setUserBeanPage(UserBean userBeanPage) {
		this.userBeanPage = userBeanPage;
	}

	public List<Integer> getAgeList() {
		return ageList;
	}

	public void setAgeList(List<Integer> ageList) {
		this.ageList = ageList;
	}

	public List<LanguageBean> getLangList() {
		return langList;
	}

	public void setLangList(List<LanguageBean> langList) {
		this.langList = langList;
	}

	public Map<String, String> getSexMap() {
		return sexMap;
	}

	public void setSexMap(Map<String, String> sexMap) {
		this.sexMap = sexMap;
	}

}
